// 引入文件
import Vue from 'vue'
import Vuex from 'vuex'

// 注册vuex
Vue.use(Vuex)


// quanxian none表示只有德客账户拥有页面权限 1表示所有代理商开发页面
const state = {
  // 账户信息
  usertype: "0", // 账户类型
  userName: "", // 代理商姓名
  userId: "", // 代理商id
  msgMargin: "", // 代理商短信余量
  accountBalance: "", // 代理商账户余额
  payEnable: "", // 代理商支付模式开关
  // 管理后台导航
  adminleftnavnum: "/",
  // 侧边栏数据
  // menuData: [],
  slideData: [{
      page_name: "商户管理",
      icon: "iconshop",
      page_path: "/admin/merchant",
      id: 1,
      quanxian: 1,
      children: [{
          page_name: "我的商户",
          page_path: "myMerchant",
          id: 2,
          quanxian: 1
        },
        {
          page_name: "过期商户",
          page_path: "overdueMerchants",
          id: 3,
          quanxian: 1
        },
        // {
        //   page_name: "二级代理商户",
        //   page_path: "secondary",
        //   id: 4,
        //   quanxian: "none",
        // disabled: true
        // }
        {
          page_name: "商户来源",
          page_path: "source",
          id: 5,
          quanxian: "none",
        }
      ]
    }, {
      page_name: "商户调整",
      icon: "icon-tiaozheng",
      page_path: "/admin/merchantsToAdjust",
      id: 31,
      quanxian: 1,
      children: []
    },
    {
      page_name: "订单管理",
      icon: "iconorder",
      page_path: "/admin/order",
      id: 6,
      quanxian: 1,
      children: [{
          page_name: "软件订单",
          page_path: "versionsOrder",
          id: 7,
          quanxian: 1
        },
        {
          page_name: "硬件订单",
          page_path: "hardwareOrder",
          id: 8,
          quanxian: "none"
        },
        {
          page_name: "增值订单",
          page_path: "appreciationOrder",
          id: 9,
          quanxian: 1
        },
        {
          page_name: "短信订单",
          page_path: "msgOrder",
          id: 10,
          quanxian: 1
        },
        {
          page_name: "短信变动记录",
          page_path: "msgChanges",
          id: 11,
          quanxian: 1
        }
      ]
    },
    {
      page_name: "待办事项",
      icon: "iconnaozhong1",
      page_path: "/admin/schedule",
      id: 12,
      quanxian: 1,
      children: [{
          page_name: "小程序申请记录",
          page_path: "appApplication",
          id: 13,
          quanxian: "none",
        },
        {
          page_name: "支付申请记录",
          page_path: "payApplication",
          id: 14,
          quanxian: "none",
        },
        {
          page_name: "支付申请资料",
          page_path: "payInformation",
          id: 33,
          quanxian: 1
        }
      ]
    },
    {
      page_name: "账户信息",
      icon: "iconshezhi1",
      page_path: "/admin/account",
      id: 15,
      quanxian: 1,
      children: [{
          page_name: "个人资料",
          page_path: "personalData",
          id: 16,
          quanxian: 1
        },
        {
          page_name: "密码修改",
          page_path: "changePassword",
          id: 17,
          quanxian: 1
        },
        {
          page_name: "短信充值",
          page_path: "msgRecharge",
          id: 18,
          quanxian: 1
        },
        {
          page_name: "角色管理",
          page_path: "roleControl",
          id: 19,
          quanxian: 1
        },
        {
          page_name: "用户管理",
          page_path: "userControl",
          id: 20,
          quanxian: 1
        },
        {
          page_name: "操作日志",
          page_path: "operationLog",
          id: 32,
          quanxian: 1
        },
        {
          page_name: "支付配置",
          page_path: "settingPayFor",
          id: 21,
          quanxian: 1
        },
        {
          page_name: "主页自定义",
          page_path: "customization",
          id: 22,
          quanxian: 1
        }
      ]
    },
    {
      page_name: "结算中心",
      icon: "iconcalendar-alt",
      page_path: "/admin/detail",
      id: 23,
      quanxian: 1,
      children: [{
          page_name: "结算明细",
          page_path: "billingDetails",
          id: 24,
          quanxian: 1
        },
        {
          page_name: "余额变动",
          page_path: "personalDetails",
          id: 25,
          quanxian: 1
        },
        {
          page_name: "短信变动",
          page_path: "merchantMsgChanges",
          id: 26,
          quanxian: 1
        }
      ]
    },
    {
      page_name: "帮助中心",
      icon: "iconbangzhu",
      page_path: "/admin/help",
      id: 27,
      quanxian: 1,
      children: [{
          page_name: "反馈问题",
          page_path: "feedback",
          id: 28,
          quanxian: "none"
        },
        {
          page_name: "软件下载",
          page_path: "downloads",
          id: 29,
          quanxian: 1
        },
        {
          page_name: "常见问题",
          page_path: "problem",
          id: 30,
          quanxian: 1
        }
      ]
    },
    {
      page_name: "需求管理",
      icon: "iconzengzhifuwu",
      page_path: "/admin/demand",
      id: 32,
      quanxian: "none",
      children: []
    },
  ],
}
const mutations = {
  'SET_USERTYPE': (state, usertype) => { // 账户类型
    state.usertype = usertype
  },
  'SET_USERNAME': (state, userName) => { // 代理商姓名
    state.userName = userName
  },
  'SET_USERID': (state, userId) => { // 代理商id
    state.userId = userId
  },
  'SET_USERMSG': (state, msgMargin) => { // 代理商短信余量
    state.msgMargin = msgMargin
  },
  'SET_USERACCOUNT': (state, accountBalance) => { // 代理商账户余额
    state.accountBalance = accountBalance
  },
  'SET_SLIDEDATA': (state, slideData) => { // 侧边栏数据
    state.slideData = slideData
  },
}
const actions = {
  setUserType: ({ // 账户类型
    commit
  }, usertype) => {
    return commit('SET_USERTYPE', usertype)
  },
  setUserName: ({ // 代理商姓名
    commit
  }, userName) => {
    return commit('SET_USERNAME', userName)
  },
  setUserId: ({ // 代理商id
    commit
  }, userId) => {
    return commit('SET_USERID', userId)
  },
  setUserMsg: ({ // 代理商短信余量
    commit
  }, msgMargin) => {
    return commit('SET_USERMSG', msgMargin)
  },
  setUserAccount: ({ // 代理商账户余额
    commit
  }, accountBalance) => {
    return commit('SET_USERACCOUNT', accountBalance)
  },
  setslideData: ({ // 侧边栏数据
    commit
  }, slideData) => {
    return commit('SET_SLIDEDATA', slideData)
  }
}
const getters = { //实时监听state值的变化(最新状态)
  userType: state => state.usertype,
  // menuData: state => state.menuData,
  // }
};
//注册Store
export default new Vuex.Store({
  state,
  mutations,
  actions,
  getters
});
